﻿using System.Windows;
using Prism.Ioc;
using Prism.Regions;

namespace ChatClient.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    // ReSharper disable once RedundantExtendsListEntry
    public partial class MainWindow : HandyControl.Controls.Window
    {
        private readonly ChatView _chatView;

        private readonly IRegionManager _regionManager;
        private IRegion? _contentRegion;

        public MainWindow(
            IContainerExtension container,
            IRegionManager regionManager
        )
        {
            InitializeComponent();

            _regionManager = regionManager;

            _chatView = container.Resolve<ChatView>();
        }

        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            _contentRegion = _regionManager.Regions["ContentRegion"];
            _contentRegion?.Add(_chatView);
            _contentRegion?.Activate(_chatView);
        }
    }
}